$(function(){
    $('form.profile-form').hide();
    $('div.profile-show').show();
    
    var editor = new baidu.editor.ui.Editor({
        textarea: 'content'
    }),editor_en = new baidu.editor.ui.Editor({
        textarea: 'content_en'
    });
    
    editor.render('content');
    editor_en.render('content_en');
    
    Z.tab($('form ul.tab-button a'),$('form div.tab-content'),['active','']);
    
    $('a.add, a.edit').click(function(){
        $('div.profile-show').hide();
        $('form.profile-form').show();
    });
    
    $('a.back').click(function(){
        $('div.profile-show').show();
        $('form.profile-form').hide();
    });
    
    $('form.profile-form').submit(function(){
	editor.sync();
	editor_en.sync();
        Z.ajax({
            url: $(this).attr('action'),
            type: $(this).attr('method'),
            data: $(this).serialize(),
            success: function(){
                window.location.reload();
            }
        });
        return false;
    });
});